import { PrismaClient , Prisma } from '../prisma-client'
export interface PrismaHandler<T> {
    (prisma: PrismaClient): Promise<T>;
}
export const usePrisma = async <T>(handler: PrismaHandler<T>): Promise<T> => {
    const prisma = new PrismaClient()
    await prisma.$connect();
    const res = await handler(prisma)
    await prisma.$disconnect();
    return res;
}
export default usePrisma;

export {
    PrismaClient, Prisma
}